#include <sstream>
#include <fstream>
#include <string>
#include <iostream>
using namespace std;

int main(int argc, char* argv[])
{
	char ABC[27] ="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	ofstream ofs ("Out.txt");
	char pass[6] = "AAAAA";
	bool hasExited = false;
	while(!hasExited)
	{
		
		int loop[4] ;
		for(loop[0] = 0; loop[0]<26;loop[0]++, cout<<pass[0])
		for(loop[1] = 0; loop[1]<26;loop[1]++)
		for(loop[2] = 0; loop[2]<26;loop[2]++)
		for(loop[3] = 0; loop[3]<26;loop[3]++)
		for(loop[4] = 0; loop[4]<26;loop[4]++){
		bool possible = true;
		for(int i = 0 ;i<5;i++)
		{
			int nb = 1;
			for(int j = 1; j<5; j++)
			{
				if(loop[i] == loop[j])nb++;
			}
			if(nb<3)
			{
				pass[i] = ABC[loop[i]];
			}
			else{
				possible = false;
				break;
			}
		}
		if(possible)ofs<<pass[0]<<pass[1]<<pass[2]<<pass[3]<<pass[4]<<endl;
		}
	}
	
	system("pause");
	return 0;
}
